package com.project.myproject.字节;

import javax.sql.DataSource;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @author Honorable(mabingqian)
 * @description
 * @date 2020/7/16 12:54
 * @update （更新、优化，注明点）
 */
public class DataClass {
    int one = 1;

    int two = getTwo();

    // 静态代码块
    static {
        System.out.println("父类静态代码块被实例化了...");
    }


    {
        int three = 3;
        System.out.println("FatherOne:" + one + "," + "FatherTwo:" + two + "," + "FatherThree" + three);
    }

    // 构造函数
    public DataClass() {
        this(4);
        System.out.println("父类无参构造函数...");
    }

    public DataClass(int num) {
        System.out.println("父类带参数的构造函数..." + num);
    }

    int getTwo() {
        System.out.println("父类getTwo方法...");
        return 2;
    }

    public void methodFirst() {
        System.out.println("Hi,我是methodFirst...");
    }
}


class Child extends DataClass {
    int childOne = 11;
    int childTwo = getChildTwo();

    {
        int childThree = 33;
        System.out.println("childOne:" +childOne +"," + "childTwo: " +childTwo + "," + "childThree:" +childThree);
    }

    public Child(){
        this(88);
        System.out.println("childClazz's construct function!");
    }

    public Child(int num) {
        System.out.println("childClazz's construct function with variable : " + num);
    }

    {
        System.out.println("childClazz is starting...");
    }

    public int getChildTwo() {
        System.out.println("Hi, I'm childClazz's getTwo method ...");
        return 22;
    }

    static {
        System.out.println("childClazz static code is running ...");
    }

    @Override
    public void methodFirst() {
        System.out.println("method is childClazz");
        super.methodFirst();
    }
}


class Main {
    public static void main(String[] args) {
        Child childClazz = new Child();
    }
}